package server

import (
	"sync"
)

// AgentStore ...
type AgentStore struct {
	sync.RWMutex
	Agents map[string]*Agent
}

// NewAgentStore ....
func NewAgentStore() *AgentStore {
	return &AgentStore{
		Agents: make(map[string]*Agent),
	}
}

// Get ...
func (as *AgentStore) Get(key string) (*Agent, bool) {
	as.RLock()
	defer as.RUnlock()
	agent, ok := as.Agents[key]
	return agent, ok
}

// Insert ...
func (as *AgentStore) Insert(key string, agent *Agent) {
	as.Lock()
	as.Agents[key] = agent
	as.Unlock()
}

// Agent ...
type Agent struct {
	ID   string
	Host string
	URL  string
	UID  string
}

// NewAgent ...
func NewAgent() *Agent {
	return &Agent{}
}
